package gui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.Toolkit;
import java.awt.image.ImageObserver;
import java.text.AttributedCharacterIterator;
import java.util.ArrayList;

import javax.swing.JPanel;
import javax.swing.text.FieldView;

import dao.Field;

import service.Service;

import model.Location;
import model.MapObject;
import model.Mob;
import model.SuperMob;

class PanelFieldRect extends JPanel {
	
	private final int scalarFactor = 50;
	private int gridDepth;
	private int gridWidth;
	Dimension size;
		
	
	
	public PanelFieldRect(int depth, int width){
		this.gridDepth = depth;
		this.gridWidth = width;
		size = new Dimension(0,0);
		setBackground(Color.WHITE);
		
	}
	
	public Dimension getPreferredSize(){
		return new Dimension(gridWidth * scalarFactor, gridDepth * scalarFactor);
	}
	
	
	
	public void paint(Graphics g){
		Service s = Service.getService();
		Field field = s.getField();
		
		for(int row = 0; row < gridDepth;row++){
			for(int col = 0; col < gridWidth; col++){
				g.setColor(Color.white);
				g.fillRect(col*scalarFactor,row*scalarFactor,scalarFactor-5,scalarFactor-5);
			}
			
		}
		this.paintMark(field, g);
	
		
				
	}
	
			
	public void paintMark(Field field,Graphics g){
		
		for(int row = 0; row < field.getDepth();row++){
			for(int col = 0; col < field.getWidth(); col++){
				if(field.getObjectAt(row, col)!= null){
					MapObject mo = (MapObject) field.getObjectAt(row, col);
					g.setColor(mo.getColor());
					g.fillRect(col*scalarFactor,row*scalarFactor,scalarFactor-5,scalarFactor-5);
				}
			}
		}
			
	}
	
				
	
						
}


	

